package com.haoliang.spring.component.java.config;

import com.haoliang.spring.component.java.condition.LinuxCondition;
import com.haoliang.spring.component.java.condition.MacCondition;
import com.haoliang.spring.component.java.condition.WindowsCondition;
import com.haoliang.spring.component.java.model.PersonModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @Author zhaohaoliang
 * @Date 创建于 上午11:51 2019/3/10
 * @Description 请输入类的描述信息
 */
// 满足条件，该类中配置的所有bean才会生效
@Conditional({WindowsCondition.class})
@Configuration
public class MainConditionalConfig {

    @Bean(value = "xuzhu")
    public PersonModel getPersonModelXu() {
        return new PersonModel("虚竹", 20);
    }

    @Conditional({WindowsCondition.class})
    @Bean(value = "lihuchong")
    public PersonModel getPersonModelLi() {
        return new PersonModel("令狐冲", 20);
    }
    @Conditional({MacCondition.class})
    @Bean(value = "renyingying")
    public PersonModel getPersonModelRen() {
        return new PersonModel("任盈盈", 20);
    }
    @Conditional({LinuxCondition.class})
    @Bean(value = "qiaofeng")
    public PersonModel getPersonModelQiao() {
        return new PersonModel("乔峰", 20);
    }
}
